package com.ithappy.oop;

public class TestExtends {
    public static void main(String[] args) {
        Student s1 = new Student("wyw",165,"software engineering");
        //s1是由Student所创建的对象，而Student是Person的子类，所以s1也属于Person
        System.out.println(s1 instanceof Student);  //输出为true
        System.out.println(s1 instanceof Person);   //输出为true
    }
}

class Person{
    String name;
    int height;
    public void rest(){
        System.out.println("休息！");
    }
}

class Student extends Person{
    String name;
    int height;
    String major;
    //因为父类Person中有rest()，在子类中不写也可以调用rest()
//    public void rest(){
//        System.out.println("休息！");
//    }

    public void study(){
        System.out.println("学习！");
        rest();
        System.out.println(this.name);
    }

    public Student(String name,int height,String major){
        this.name = name;
        this.height = height;
        this.major = major;
    }
}

class girl extends Person{
    String name;
}